package com.serviceImpl;

import com.dao.CommentDao;
import com.domain.Comment;
import com.server.CommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service("commentService")
public class CommentServiceImpl implements CommentService{


    @Resource(name="commentDao")
    private CommentDao commentDao;


    @Override
    public Comment selectCommentById(int id) {
        return commentDao.selectCommentById(id);
    }

    @Override
    public List<Comment> selectCommentByDiscussId(int discuss_id) {
        return commentDao.selectCommentByDiscussId(discuss_id);
    }

    @Override
    public List<Comment> selectCommentByContributeId(Integer contribute_id) {
        return commentDao.selectCommentByContributeId(contribute_id);
    }

    @Override
    public int selectCommentTotalByDiscussId(int discuss_id) {
        return commentDao.selectCommentTotalByDiscussId(discuss_id);
    }

    @Override
    public int selectCommentTotalByContributeId(Integer contribute_id) {
        return commentDao.selectCommentTotalByContributeId(contribute_id);
    }

    @Override
    public int addComment(Comment comment) {
        return commentDao.addComment(comment);
    }

    @Override
    public int deleteCommentById(int id) {
        return commentDao.deleteCommentById(id);
    }

    @Override
    public List<Comment> selectCommentAndPageLimitById(int discuss_id, int page, int pageSize) {
        int from=(page-1)*pageSize;
        return commentDao.selectCommentAndPageLimitById(discuss_id,from,pageSize);
    }

    @Override
    public List<Comment> selectContributeCommentAndPageLimitById(int contribute_id, int page, int pageSize) {
        int from=(page-1)*pageSize;
        return commentDao.selectContributeCommentAndPageLimitById(contribute_id,from,pageSize);
    }

    @Override
    public List<Comment> selectResourceCommentAndPageLimitById(int resource_id, int page, int pageSize) {
        int from=(page-1)*pageSize;
        return selectResourceCommentAndPageLimitById(resource_id, from,pageSize);
    }

    @Override
    public List<Comment> showCommentByResourceId(Integer id) {
        return commentDao.showCommentByResourceId(id);
    }

    @Override
    public List showCommentById(Integer id) {
        return commentDao.showCommentById(id);
    }

}
